package com.weaver.drools.business.execution.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.weaver.drools.business.execution.service.IEAqInsSupervisor129Service;
import com.weaver.drools.common.dao.EAqInsSupervisor129Dao;
import com.weaver.drools.common.entity.EAqInsSupervisor129;
@Service
public class EAqInsSupervisor129ServiceImpl implements IEAqInsSupervisor129Service {

	@Autowired
	private EAqInsSupervisor129Dao EAqInsSupervisor129Dao;
	@Override
	public EAqInsSupervisor129 findById(Long supervisorid) {
		// TODO Auto-generated method stub
		return EAqInsSupervisor129Dao.findEAqInsSupervisor129BySupervisorid(supervisorid);
	}

	@Override
	public void saveEAqInsSupervisor129(EAqInsSupervisor129 aqInsSupervisor129) {
		EAqInsSupervisor129Dao.saveOrUpdate(aqInsSupervisor129);
	}

	@Override
	public void updateEAqInsSupervisor129(EAqInsSupervisor129 aqInsSupervisor129) {
		EAqInsSupervisor129Dao.saveOrUpdate(aqInsSupervisor129);
	}

	@Override
	public void deleteById(Long supervisorid) {
		EAqInsSupervisor129Dao.deleteById(supervisorid);
	}

	@Override
	public List<EAqInsSupervisor129> findList(Long bpTypeId, Long objectId, String inpectionId, String contactId)
			throws Exception {
		String hql="from EAqInsSupervisor129 where isdeleted=0";
		if(bpTypeId!=null){
			hql+=" and DBptype113.bptypeid="+bpTypeId;
		}
		if(objectId!=null){
			hql+=" and objectid="+objectId;
		}
		if(inpectionId!=null && !inpectionId.equals("")){
			hql+=" and EAqInsInpection124.inpectionid="+inpectionId;
		}
		if(contactId!=null && !contactId.equals("")){
			hql+=" and QSelfEnemploycontact72.contactid ="+contactId;
		}
		hql+=" order by supervisorid desc";
		return EAqInsSupervisor129Dao.findListByhql(hql);
	}

}
